import javax.naming.PartialResultException;
import java.util.Arrays;
import java.util.Scanner;


public class TestDemo {
    //3.奇数在偶数之前
    public static void copySort(int[] array) {
        int left = 0;//left表示奇数
        int right = array.length-1;//right表示偶数
        while(left < right){//判断循环条件
            while (left < right && array[left] % 2 != 0){//通过这个下标来索引
                left++;//如果是用取余来算数，并且全是奇数的数组，所以会一直往下取模，就会造成数组越界
            }
            while(left < right && array[right] % 2 == 0){//通过这个下标来索引
                right--;//如果是用取余来算数，并且全是偶数的数组，所以会一直往下取模，就会造成数组越界
            }
            int temp = array[left];
            array[left] = array[right];
            array[right] = temp;
        }
    }
    public static void main1(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < array.length; i++) {
            array[i] = sc.nextInt();
        }
        copySort(array);
        System.out.println(Arrays.toString(array));
    }

    //5.oj题：两数之和
    public static  int[] func(int[] array,int key){
        for (int i = 0; i < array.length-1; i++) {
            //i是两个数的第一个数
            for (int j = 0; j < array.length; j++) {
                //j是两个数中的第二个数
                if(array[i] + array[j] == key){
                    return new int[]{i,j};//返回一个数组
                }
            }
        }
        return new int[]{-1,-1};
    }
    public static void main2(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < array.length; i++) {
            array[i] = sc.nextInt();
        }
        System.out.println(Arrays.toString(array));
        int target = sc.nextInt();
        int[] ret = func(array,target);
        System.out.println(Arrays.toString(ret));
    }

    //6.只出现一次的数字
    public static int func(int[] arr){
        int ret = arr[0];
        for (int i = 1; i < arr.length; i++) {
            ret  ^= arr[i];
        }
        //通过异位或的运算，相同的数异或是0，任何的数异或的是还是原来的数
        //相同为0，不同为1
        return ret;
    }
    public static void main3(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < array.length; i++) {
            array[i] = sc.nextInt();
        }
        System.out.println(Arrays.toString(array));

        System.out.println(func(array));
    }

    //7.多数元素
    //这道题数组一定是存在多数元素的
    public static int func1(int[] array){
        Arrays.sort(array);
        return  array[array.length / 2];
        //这种就是排序，若该数组总是存在多数元素，那么我通过排序后，那么往往中间的是那个多数的元素
    }
    public static void main4(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < array.length; i++) {
            array[i] = sc.nextInt();
        }
        System.out.println(Arrays.toString(array));
        func1(array);
        System.out.println(func1(array));
    }

    //8.存在连续三个奇数的数组
    //我的想法：
        public static boolean existsThreeOdds(int[] arr) {
            if (arr.length < 3) {
                return false;
            }
            for (int i = 0; i <= arr.length - 3; i++) {
                int a = arr[i];
                int b = arr[i+1];
                int c = arr[i+2];
                if ((a % 2 != 0) && (b % 2 != 0) && (c % 2 != 0)) {
                    return true;
                }
            }
            return false;
        }

    public static void main5(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < array.length; i++) {
            array[i] = sc.nextInt();
        }
        System.out.println(Arrays.toString(array));
        boolean flg = existsThreeOdds(array);
        System.out.println(flg);
    }

    public static boolean xjy(int[] arr){
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] % 2 != 0){//这时候奇数我就加
                count++;
                if(count == 3){
                    return  true;
                }
            }else{
                count = 0;//当遇到偶数的时候，那就是表明不是连续的奇数，再重新计算
            }
        }
        return false;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < array.length; i++) {
            array[i] = sc.nextInt();
        }
        System.out.println(Arrays.toString(array));
        boolean flg = xjy(array);
        System.out.println(flg);
    }
}
